const express = require("express");
const db = require('../../utils/db')
const router = express.Router();

//初始化查询
//使用“select 字段列表 from 表1,表2 [where 条件]”进行查询；
//2、使用“SELECT 字段列表 FROM 表1 关键字 JOIN 表2 ON 表1.字段 = 表2.字段;”进行查询。
router.post('/oneproject',(req,res)=>{
   // const n = `select * from contacts Information JOIN account ON contacts.Information = account.id;`
    const k = `select count(*) from contacts,account where contacts.Information = account.id;`
    const {createmen,title,startTime,state} = req.body;
    console.log(createmen,title,startTime,state);
    const mysql = `select * from contacts where closeState=1`;
    //select date_format(regTime, '%Y-%m') , count(*)  from contacts where closeState=1 group by date_format(regTime, '%Y-%m');
    const mysql1 = `select * from contacts where closeState=2`;
    const mysql2 = `select * from contacts where closeState=3`;
    db.query(mysql,(err,data)=>{
        console.log(data,err)
        if(err){
            res.send('错误');
        }else{
            db.query(mysql,(err1,data1)=>{
                db.query(mysql,(err2,data2)=>{
                    res.send({mijie:data,cijie:data1,yiban:data2})
                })
            })
            res.send({msg:data})
        }
    })
})
//密集人群表
//初始化查询
router.post('/oneproject',(req,res)=>{
   
    db.query(mysql,(err,data)=>{
        console.log(data,err)
        if(err){
            res.send('错误');
        }else{
            res.send(data);
        }
    })
})
module.exports = router;